package com.yjha.lzmarathonsys.controller;

import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yjha.lzmarathonsys.bean.TbImagesl;
import com.yjha.lzmarathonsys.service.TbImageslService;
import com.yjha.lzmarathonsys.utils.PageUtils;
import com.yjha.lzmarathonsys.utils.R;
import org.springframework.web.multipart.MultipartFile;


/**
 * 图片存储表
 *
 * @author æ­å°
 * @email 1971240051@qq.com
 * @date 2025-05-13 15:07:07
 */
@Api(tags = "图片存储表")
@RestController
@RequestMapping("lzmarathonsys/tbimagesl")
// @CrossOrigin
public class TbImageslController {
    @Autowired
    private TbImageslService tbImageslService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation("获取图片列表")
    //@RequiresPermissions("lzmarathonsys:tbimagesl:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbImageslService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{tbId}")
    @ApiOperation("获取图片详情")
    //@RequiresPermissions("lzmarathonsys:tbimagesl:info")
    public R info(@PathVariable("tbId") Integer tbId){
		TbImagesl tbImagesl = tbImageslService.getById(tbId);

        return R.ok().put("tbImagesl", tbImagesl);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("保存图片")
    //@RequiresPermissions("lzmarathonsys:tbimagesl:save")
    public R save(@RequestBody TbImagesl tbImagesl){
		tbImageslService.save(tbImagesl);

        return R.ok();
    }

    @ApiOperation("文件上传")
    @PostMapping("/fileUplod")
    public R fileUplod(String id, @RequestPart  MultipartFile[] files) throws IOException {
        R r = tbImageslService.fileUpload(id, files);
        return r;
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改图片")
    //@RequiresPermissions("lzmarathonsys:tbimagesl:update")
    public R update(@RequestBody TbImagesl tbImagesl){
		tbImageslService.updateById(tbImagesl);

        return R.ok();
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @ApiOperation("删除图片")
    //@RequiresPermissions("lzmarathonsys:tbimagesl:delete")
    public R delete(@RequestBody Integer[] tbIds){
		tbImageslService.removeTbImageslByIds(Arrays.asList(tbIds));

        return R.ok();
    }

}
